<html>
<head><meta charset="utf-8"><title>Revisiting `exhaustive_patterns` #51085 · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html">Revisiting `exhaustive_patterns` #51085</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209173145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173145">(Sep 05 2020 at 11:08)</a>:</h4>
<p>(This is the "<code>Ok(x)</code> is irrefutable for <code>Result&lt;_, !&gt;</code>" feature.)</p>
<p>Looks like this hasn't really gone anywhere since 2018.  It still seems reasonable to me (adding a variant is breaking already), since it feels weird to have the to write the <code>Err(e) =&gt; match e {}</code> arm when that second <code>match</code> is showing that we don't it's not needed here.</p>
<p>Are we still happy with it in principle?  Would a <a href="https://github.com/rust-lang/rust/issues/51085#issuecomment-430380775">"sufficiently conservative definition"</a> still be able to unblock this?  I'd be fine with a <code>min_*</code> version of this that just handled things like <code>std::convert::Infallible</code>...</p>
<p>(I'm running into this going back to <code>Try</code> experiments again, using types like <code>Option&lt;Infallible&gt;</code>.)</p>



<a name="209173295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173295">(Sep 05 2020 at 11:12)</a>:</h4>
<p>IIRC the latest discussions here were around explicit <code>!</code> patterns and under which condition they would be implicitly inferred?</p>



<a name="209173434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173434">(Sep 05 2020 at 11:17)</a>:</h4>
<p>Oh, was <a href="http://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/">http://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/</a> not what was implemented?  I guess probably not, given the time frames between that post and comments about the implementation having poor perf.</p>



<a name="209173727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173727">(Sep 05 2020 at 11:26)</a>:</h4>
<p>yeah I dont think that proposal was ever RFC'd, let alone implemented</p>



<a name="209173728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173728">(Sep 05 2020 at 11:26)</a>:</h4>
<p>Also, it wasn't clear to me whether the intent was to actually expose <code>Err(!)</code> as a pattern in user-visible syntax, or just as a way to represent it in THIR?</p>



<a name="209173735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173735">(Sep 05 2020 at 11:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085/near/209173728">said</a>:</p>
<blockquote>
<p>Also, it wasn't clear to me whether the intent was to actually expose <code>Err(!)</code> as a pattern in user-visible syntax, or just as a way to represent it in THIR?</p>
</blockquote>
<p>I don't think there was consensus on that. FWIW I think it would be nice to expose this to the user.</p>



<a name="209173749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209173749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209173749">(Sep 05 2020 at 11:27)</a>:</h4>
<p>the plan was to at least expose things like <code>&amp;!</code> to make the deref explicit -- but again, that was mostly just Niko and me talking, not a wider t-lang discussion. IIRC.</p>



<a name="209174004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209174004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209174004">(Sep 05 2020 at 11:34)</a>:</h4>
<p>And if I'm reading things right, it's just behind the reference that things get complicated?  For the other cases matching on it already required that all the fields be valid, so seeing it isn't helpful in the same way there?</p>



<a name="209174070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209174070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209174070">(Sep 05 2020 at 11:36)</a>:</h4>
<p><code>unions</code> are also special</p>



<a name="209174076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209174076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209174076">(Sep 05 2020 at 11:37)</a>:</h4>
<p>AFAIK we have patterns for those but they are unsafe or so?</p>



<a name="209174084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Revisiting%20%60exhaustive_patterns%60%20%2351085/near/209174084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Revisiting.20.60exhaustive_patterns.60.20.2351085.html#209174084">(Sep 05 2020 at 11:37)</a>:</h4>
<p>but for everything else, indeed there's already UB earlier. however as a user I feel like I still might want to make the <code>!</code> explicit sometimes... but it probably should not be required.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>